package com.igeekhome.ccs.controller;

import com.igeekhome.ccs.biz.ICustomerFieldBiz;
import com.igeekhome.ccs.entity.CustomerField;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

@Controller
@RequestMapping("/cf")
public class CustomerFieldController {
    @Autowired
    ICustomerFieldBiz iCustomerFieldBiz;
//👇zyh--------------------------------------------------------------
    //对外提供所有客户字段
    @GetMapping("/query")
    public @ResponseBody
    List<CustomerField> query(){return iCustomerFieldBiz.query();}

    //做搜索
    @GetMapping("/queryCsByString")
    public @ResponseBody
    List<CustomerField> queryCsByString(@RequestParam String str){return iCustomerFieldBiz.queryCsByString(str);}

    //增加
    @PostMapping("/createCf")
    public @ResponseBody
    int createCf(@RequestBody CustomerField customerField) throws ParseException {iCustomerFieldBiz.createCf(customerField);return 0;}

    //删除
    @DeleteMapping("/deleteCf")
    public @ResponseBody
    int deleteCf(@RequestParam int fieldId) {iCustomerFieldBiz.deleteCf(fieldId);return 0;}

    //编辑
    @PostMapping("/editCf")
    public @ResponseBody
    int editCf(@RequestParam int fieldId,@RequestParam String fieldName,@RequestParam boolean mustOrNot,@RequestParam String fieldType) {iCustomerFieldBiz.editCf(fieldId,fieldName,mustOrNot,fieldType);return 0;}

//👆zyh---------------------------------------------------------------
}
